package com.jason.demo.two.model

import android.widget.ImageView
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import androidx.databinding.BindingAdapter
import com.jason.demo.two.BR
import com.jason.demo.two.R

/**
 * @author ChenBaoyang
 * @description: A
 * @date 5/8/21 16:34
 */
class GoodInfo : BaseObservable() {

    var name: String? = null

    @Bindable
    var nick: String? = null
        set(nick) {
            field = nick
            notifyPropertyChanged(BR.nick)
        }

    @Bindable
    var resId = R.mipmap.ic_launcher
        set(resId) {
            field = resId
            notifyPropertyChanged(BR.resId)
        }
    var price = 100

    @Bindable
    var isVip = true

    companion object {
        @BindingAdapter("imageUrl")
        fun loadImage(imageView: ImageView, resId: Int) {
            imageView.setImageResource(resId)
        }
    }
}